#include <cstdio>
using namespace std;

const int N = 50010;
int n, L;
long long sum[N], f[N];
int q[N];

inline double a(int i) {
	return i + sum[i];
}

inline double b(int i) {
	return i + sum[i] + L + 1;
}

inline double y(int i) {
	return f[i] + b(i) * b(i);
}

double solve(int i, int j) {
	return (y(i) - y(j)) / (b(i) - b(j));
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef DEBUG
	freopen("P3195.in", "r", stdin);
	freopen("P3195.out", "w", stdout);
#endif
#endif
	scanf("%d%d", &n, &L);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &sum[i]);
		sum[i] += sum[i - 1];
	}
	int head = 1, tail = 1;
	for (int i = 1; i <= n; ++i) {
		while (head < tail && 2.0 * a(i) > solve(q[head], q[head + 1])) ++head;
		f[i] = f[q[head]] + (a(i) - b(q[head])) * (a(i) - b(q[head]));
		while (head < tail && solve(q[tail], i) < solve(q[tail - 1], q[tail])) --tail;
		q[++tail] = i;
	}
	printf("%lld", f[n]);
	return 0;
}